package cn.com.yusys.trace.client;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.com.yusys.trace.client.api.ApplyFeignApi;
import cn.com.yusys.trace.client.api.GoodsFeignApi;

@RestController
public class ClientController {
    
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private ApplyFeignApi applyFeignApi;
    @Autowired
    private GoodsFeignApi goodsFeignApi;
    
    @GetMapping("/client")
    public String selectClientData() {
        logger.info("我是guage----guage开始正在执行client工程中selectClientData方法----------------------");
        int a=5;int b=0;
     /*   try {
			long c = a/b;
		} catch (Exception e) {
			e.printStackTrace();
		    logger.error("aaaaaaaaaa"+e);
		}*/
        String result="error";
		try {
			result = applyFeignApi.selectApplyData();
	        logger.info("applyFeignApi返回结果为----------------------"+result);
		} catch (Exception e) {
			logger.error("",e);
		}
        logger.info("client工程中selectClientData方法执行结束,查询结果为：----------------------"+result);
        try {
			logger.info("我是guage----guage开始正在执行client工程中selectGoodsData方法----------------------");
			String goods =  goodsFeignApi.selectGoodsData();
			result = result+goods;
			logger.info("client工程中selectGoodsData方法执行结束,查询结果为：----------------------"+goods);
		} catch (Exception e) {
			logger.error("",e);
		}

        return result;
        //return "test";
    }
    
    @GetMapping("/getUser")
    public String getUser() {
        logger.info("我是guage----guage开始正在执行client工程中selectClientData方法----------------------");
        int a=5;int b=0;
     /*   try {
			long c = a/b;
		} catch (Exception e) {
			e.printStackTrace();
		    logger.error("aaaaaaaaaa"+e);
		}*/
        String result="error";
		try {
			result = applyFeignApi.selectApplyData();
	        logger.info("applyFeignApi返回结果为----------------------"+result);
		} catch (Exception e) {
			logger.error("",e);
		}
        logger.info("client工程中selectClientData方法执行结束,查询结果为：----------------------"+result);
        return result;
        //return "test";
    }
    
    @GetMapping("/test")
    public String test() {
         return "client";
    }
    
    @GetMapping("/getGoods")
    public String getGoods() {
    	String goods = "error";
        try {
			logger.info("我是guage----guage开始正在执行client工程中selectGoodsData方法----------------------");
			goods =  goodsFeignApi.selectGoodsData();
			logger.info("client工程中selectGoodsData方法执行结束,查询结果为：----------------------"+goods);
		} catch (Exception e) {
			logger.error("",e);
		}

        return goods;
    }
}